<?
include "loggedin.inc.php";
require('../includes/messages.inc.php');
require('../includes/config.inc.php');
require("header.php");
require('../includes/styles.inc.php');

$q1 = "select * from PHPAUCTION_links where LinkID = '$_GET[LinkID]' ";
$r1 = mysql_query($q1) or die(mysql_error());
if(isset($_POST[s1]))
{
	//get the original file name

	if(empty($_POST[LinkURL]) || empty($_POST[LinkName]))
	{
		echo "<center><br><font color=red size=2 face=verdana><b>All fields are required!</b></font></center>";
	}
	else
	{

		$q1 = "update PHPAUCTION_links set
					LinkName = '$_POST[LinkName]',
					LinkURL = '$_POST[LinkURL]'

					where LinkID = '$_GET[LinkID]' ";

		mysql_query($q1) or die(mysql_error());

	header("location:links.php?&succ=1");
	exit();
	}
}

$a1 = mysql_fetch_array($r1);
?>

<script>

function NewBanner() {

	if(document.f1.BannerFile.value=="")
	{
		alert('Select the banner file from your computer!');
		document.f1.BannerFile.focus();
		return false;
	}

	if(document.f1.BannerAlt.value=="")
	{
		alert('Enter the ALT text, please!');
		document.f1.BannerAlt.focus();
		return false;
	}

	if(document.f1.BannerURL.value=="" || document.f1.BannerURL.value.length < '11')
	{
		alert('Enter the URL, please!\n\nFormat: http://www.domain.com');
		document.f1.BannerURL.focus();
		document.f1.BannerURL.value="http://";
		return false;
	}

}

</script>

<form method=post enctype="multipart/form-data">
  <table align=center width=450>
    <caption align=center>
    <font size=3 face=verdana color=black><b>Edit a Link</b></font>
    </caption>
    <tr>
      <td><font size=2 face=verdana color=black><b>Link Name:</b></font></td>
      <td><input type=text name=LinkName value="<?=$a1[LinkName]?>"></td>
    </tr>
    <tr>
      <td><font size=2 face=verdana color=black><b>Link URL:</b></font></td>
      <td><input type=text name=LinkURL value="<?=$a1[LinkURL]?>"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td> <input type=submit name=s1 value="Save"> </td>
    </tr>
  </table>
</form>

</table>

<?
include("footer.php");
?>